package com.cheer.job;

import cn.hutool.core.io.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * 题库定时任务，清理从表脏数据以及io脏数据文件
 *
 * @author chufangzheng 2019/3/15
 */
@Component
public class TemplateJob {

    private static final Logger LOGGER = LoggerFactory.getLogger(TemplateJob.class);

    @Value("${document.temporary}")
    private String templatePath;

    /**
     * 每天凌晨1点执行题库定时清理任务
     */
    @Scheduled(cron = "0 0 1 * * *")
    public void repositoryClean() {
        LOGGER.info("开始清空临时文件夹目录");
        FileUtil.cleanEmpty(new File(templatePath));
        LOGGER.info("清空临时文件夹目录完成");
    }


}
